<?php defined('BASE_PATH') or die('No direct script access.');
/*** gọi class config cấu hình database ***/
include BASE_PATH . '/application/config/' . 'config.php';
include BASE_PATH . '/application/system/' . 'loader.class.php';
include BASE_PATH . '/application/system/' . 'controller.class.php';
/*** gọi class registry ***/
include BASE_PATH . '/application/system/' . 'registry.class.php';
/*** gọi class router ***/
include BASE_PATH . '/application/system/' . 'router.class.php';
include BASE_PATH . '/application/system/' . 'template.class.php';
/*** gọi class Database ***/
include BASE_PATH . '/application/system/' . 'db.class.php';
include BASE_PATH . '/application/system/' . 'model.class.php';
include LIBRARY.'request.php';
include LIBRARY.'session.php';
include LIBRARY.'language.php';
include LIBRARY.'uri.php';
/*** khởi tạo 1 đối tượng registry ***/
$registry = registry::getInstance();
// Nạp đối tượng Session
$registry->session=new Session();
/// nạp request
$registry->request=new Request();
// Nạp đối tượng Router
$registry->router = new router($registry);
//nạp database
$registry->db = new db();
$registry->uri = uri::getInstance();
// Set đường dẫn cho thư mục controller
$registry->router->setPath (BASE_PATH . '/application/modules');
// Nạp đối tượng template ***/
$registry->template = new template($registry);
// Nạp đối tượng loader ***/
$registry->load= new Loader($registry);
$registry->load->helper('common');
$query = $registry->db->query("SELECT * FROM " . DB_PREFIX . "setting");
$query=$query->fetchall();
foreach ($query as $s) {
	$registry->setting->$s['key']=$s['value'];
}
unset ($query);
unset($s);
// Load controller
$registry->router->loader();
// End of init.php